home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Games / MAME / src / drivers / munchmo.c < prev    next >
C/C++ Source or Header  |  2000-05-25  |  13KB  |  402 lines

  1. /***************************************************************************
  2.   Munch Mobile
  3.   (C) 1982 SNK
  4.  
  5.   2 Z80s
  6.   2 AY-8910s
  7.   15 MHz crystal
  8.  
  9.   Known Issues:
  10.     - sprite priority problems
  11.     - it's unclear if mirroring the videoram chunks is correct behavior
  12.     - several unmapped registers
  13.     - sustained sounds (when there should be silence)
  14.  
  15. ***************************************************************************/
  16.  
  17. #include "driver.h"
  18. #include "cpu/z80/z80.h"
  19. #include "vidhrdw/generic.h"
  20.  
  21.  
  22. extern UINT8 *mnchmobl_vreg;
  23. extern UINT8 *mnchmobl_status_vram;
  24. extern UINT8 *mnchmobl_sprite_xpos;
  25. extern UINT8 *mnchmobl_sprite_attr;
  26. extern UINT8 *mnchmobl_sprite_tile;
  27.  
  28. void mnchmobl_convert_color_prom(unsigned char *palette, unsigned short *colortable,const unsigned char *color_prom);
  29. int mnchmobl_vh_start( void );
  30. void mnchmobl_vh_stop( void );
  31. WRITE_HANDLER( mnchmobl_palette_bank_w );
  32. WRITE_HANDLER( mnchmobl_flipscreen_w );
  33. READ_HANDLER( mnchmobl_sprite_xpos_r );
  34. WRITE_HANDLER( mnchmobl_sprite_xpos_w );
  35. READ_HANDLER( mnchmobl_sprite_attr_r );
  36. WRITE_HANDLER( mnchmobl_sprite_attr_w );
  37. READ_HANDLER( mnchmobl_sprite_tile_r );
  38. WRITE_HANDLER( mnchmobl_sprite_tile_w );
  39. READ_HANDLER( mnchmobl_videoram_r );
  40. WRITE_HANDLER( mnchmobl_videoram_w );
  41. void mnchmobl_vh_screenrefresh(struct osd_bitmap *bitmap,int full_refresh);
  42.  
  43.  
  44. /***************************************************************************/
  45.  
  46. static int mnchmobl_nmi_enable = 0;
  47.  
  48. static WRITE_HANDLER( mnchmobl_nmi_enable_w )
  49. {
  50.     mnchmobl_nmi_enable = data;
  51. }
  52.  
  53. static int mnchmobl_interrupt( void )
  54. {
  55.     static int which;
  56.     which = !which;
  57.     if( which ) return interrupt();
  58.     if( mnchmobl_nmi_enable ) return nmi_interrupt();
  59.     return ignore_interrupt();
  60. }
  61.  
  62. WRITE_HANDLER( mnchmobl_soundlatch_w )
  63. {
  64.     soundlatch_w( offset, data );
  65.     cpu_cause_interrupt( 1, Z80_IRQ_INT );
  66. }
  67.  
  68. static struct MemoryReadAddress readmem[] =
  69. {
  70.     { 0x0000, 0x3fff, MRA_ROM },
  71.     { 0x8000, 0x83ff, MRA_RAM }, /* working RAM */
  72.     { 0xa000, 0xa3ff, MRA_RAM },
  73.     { 0xa400, 0xa7ff, mnchmobl_sprite_xpos_r }, /* mirrored */
  74.     { 0xa800, 0xabff, MRA_RAM },
  75.     { 0xac00, 0xafff, mnchmobl_sprite_tile_r }, /* mirrored */
  76.     { 0xb000, 0xb3ff, MRA_RAM },
  77.     { 0xb400, 0xb7ff, mnchmobl_sprite_attr_r }, /* mirrored */
  78.     { 0xb800, 0xb8ff, MRA_RAM },
  79.     { 0xb900, 0xb9ff, mnchmobl_videoram_r },    /* mirrored */
  80.     { 0xbe02, 0xbe02, input_port_3_r }, /* DSW1 */
  81.     { 0xbe03, 0xbe03, input_port_4_r }, /* DSW2 */
  82.     { 0xbf01, 0xbf01, input_port_0_r }, /* coin, start */
  83.     { 0xbf02, 0xbf02, input_port_1_r }, /* P1 controls */
  84.     { 0xbf03, 0xbf03, input_port_2_r }, /* P2 controls */
  85.     { -1 }
  86. };
  87.  
  88. static struct MemoryWriteAddress writemem[] =
  89. {
  90.      { 0x0000, 0x3fff, MWA_ROM },
  91.     { 0x8000, 0x83ff, MWA_RAM }, /* working RAM */
  92.     { 0xa000, 0xa3ff, MWA_RAM, &mnchmobl_sprite_xpos },
  93.     { 0xa400, 0xa7ff, mnchmobl_sprite_xpos_w },
  94.     { 0xa800, 0xabff, MWA_RAM, &mnchmobl_sprite_tile },
  95.     { 0xac00, 0xafff, mnchmobl_sprite_tile_w },
  96.     { 0xb000, 0xb3ff, MWA_RAM, &mnchmobl_sprite_attr },
  97.     { 0xb400, 0xb7ff, mnchmobl_sprite_attr_w },
  98.     { 0xb800, 0xb9ff, mnchmobl_videoram_w, &videoram },
  99.     { 0xba00, 0xbbff, MWA_RAM },
  100.     { 0xbc00, 0xbc7f, MWA_RAM, &mnchmobl_status_vram },
  101.     { 0xbe00, 0xbe00, mnchmobl_soundlatch_w },
  102.     { 0xbe01, 0xbe01, mnchmobl_palette_bank_w },
  103.     { 0xbe11, 0xbe11, MWA_RAM }, /* ? */
  104.     { 0xbe21, 0xbe21, MWA_RAM }, /* ? */
  105.     { 0xbe31, 0xbe31, MWA_RAM }, /* ? */
  106.     { 0xbe41, 0xbe41, mnchmobl_flipscreen_w },
  107.     { 0xbe61, 0xbe61, mnchmobl_nmi_enable_w }, /* ENI 1-10C */
  108.     { 0xbf00, 0xbf07, MWA_RAM, &mnchmobl_vreg }, /* MY0 1-8C */
  109.     { -1 }
  110. };
  111.  
  112. static struct MemoryReadAddress readmem_sound[] =
  113. {
  114.     { 0x0000, 0x1fff, MRA_ROM },
  115.     { 0x2000, 0x2000, soundlatch_r },
  116.     { 0xe000, 0xe7ff, MRA_RAM },
  117.     { -1 }
  118. };
  119. static struct MemoryWriteAddress writemem_sound[] =
  120. {
  121.     { 0x0000, 0x1fff, MWA_ROM },
  122.     { 0x4000, 0x4000, AY8910_write_port_0_w },
  123.     { 0x5000, 0x5000, AY8910_control_port_0_w },
  124.     { 0x6000, 0x6000, AY8910_write_port_1_w },
  125.     { 0x7000, 0x7000, AY8910_control_port_1_w },
  126.     { 0x8000, 0x8000, MWA_NOP }, /* ? */
  127.     { 0xa000, 0xa000, MWA_NOP }, /* ? */
  128.     { 0xc000, 0xc000, MWA_NOP }, /* ? */
  129.     { 0xe000, 0xe7ff, MWA_RAM },
  130.     { -1 }
  131. };
  132.  
  133. static struct AY8910interface ay8910_interface =
  134. {
  135.     2,    /* 2 chips */
  136.     1500000,    /* 1.5 MHz? */
  137.     { 50, 50 },
  138.     { 0 },
  139.     { 0 },
  140.     { 0 },
  141.     { 0 }
  142. };
  143.  
  144. INPUT_PORTS_START( mnchmobl )
  145.     PORT_START
  146.     PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_COIN1 )
  147.     PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN )
  148.     PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_COIN2 ) /* service */
  149.     PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_START1 )
  150.     PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_START2 )
  151.     PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNKNOWN )
  152.     PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
  153.     PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
  154.  
  155.     PORT_START /* P1 controls */
  156.     PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICKLEFT_UP | IPF_8WAY )
  157.     PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICKLEFT_DOWN | IPF_8WAY )
  158.     PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICKLEFT_LEFT | IPF_8WAY )
  159.     PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICKLEFT_RIGHT | IPF_8WAY )
  160.     PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_JOYSTICKRIGHT_LEFT | IPF_2WAY )
  161.     PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_JOYSTICKRIGHT_RIGHT | IPF_2WAY )
  162.     PORT_BIT( 0xc0, IP_ACTIVE_LOW, IPT_UNUSED )
  163.  
  164.     PORT_START /* P2 controls */
  165.     PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICKLEFT_UP | IPF_8WAY | IPF_COCKTAIL )
  166.     PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICKLEFT_DOWN | IPF_8WAY | IPF_COCKTAIL )
  167.     PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICKLEFT_LEFT | IPF_8WAY | IPF_COCKTAIL )
  168.     PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICKLEFT_RIGHT | IPF_8WAY | IPF_COCKTAIL )
  169.     PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_JOYSTICKRIGHT_LEFT | IPF_2WAY | IPF_COCKTAIL )
  170.     PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_JOYSTICKRIGHT_RIGHT | IPF_2WAY | IPF_COCKTAIL )
  171.     PORT_BIT( 0xc0, IP_ACTIVE_LOW, IPT_UNUSED )
  172.  
  173.     PORT_START    /* DSW1 0xbe02 */
  174.     PORT_DIPNAME( 0x01, 0x00, DEF_STR( Unknown ) )
  175.     PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
  176.     PORT_DIPSETTING(    0x01, DEF_STR( On ) )
  177.     PORT_DIPNAME( 0x1e, 0x00, DEF_STR( Coinage ) )
  178.     PORT_DIPSETTING(    0x14, DEF_STR( 3C_1C ) )
  179. //    PORT_DIPSETTING(    0x12, DEF_STR( 2C_1C ) )
  180.     PORT_DIPSETTING(    0x10, DEF_STR( 2C_1C ) )
  181.     PORT_DIPSETTING(    0x16, DEF_STR( 3C_2C ) )
  182.     PORT_DIPSETTING(    0x00, DEF_STR( 1C_1C ) )
  183. //    PORT_DIPSETTING(    0x1e, DEF_STR( 1C_1C ) )
  184. //    PORT_DIPSETTING(    0x1c, DEF_STR( 1C_1C ) )
  185. //    PORT_DIPSETTING(    0x1a, DEF_STR( 1C_1C ) )
  186. //    PORT_DIPSETTING(    0x18, DEF_STR( 1C_1C ) )
  187.     PORT_DIPSETTING(    0x02, DEF_STR( 1C_2C ) )
  188.     PORT_DIPSETTING(    0x04, DEF_STR( 1C_3C ) )
  189.     PORT_DIPSETTING(    0x06, DEF_STR( 1C_4C ) )
  190.     PORT_DIPSETTING(    0x08, DEF_STR( 1C_5C ) )
  191.     PORT_DIPSETTING(    0x0a, DEF_STR( 1C_6C ) )
  192.     PORT_DIPSETTING(    0x0c, DEF_STR( 1C_7C ) )
  193.     PORT_DIPSETTING(    0x0e, DEF_STR( 1C_8C ) )
  194.     PORT_DIPNAME( 0xe0, 0x00, DEF_STR( Bonus_Life ) )
  195.     PORT_DIPSETTING(    0x00, "No Bonus" )
  196.     PORT_DIPSETTING(    0x20, "70000" )
  197.     PORT_DIPSETTING(    0x40, "60000" )
  198.     PORT_DIPSETTING(    0x60, "50000" )
  199.     PORT_DIPSETTING(    0x80, "40000" )
  200.     PORT_DIPSETTING(    0xa0, "30000" )
  201.     PORT_DIPSETTING(    0xc0, "20000" )
  202.     PORT_DIPSETTING(    0xe0, "10000" )
  203.  
  204.     PORT_START    /* DSW2 0xbe03 */
  205.     PORT_DIPNAME( 0x03, 0x00, "Second Bonus Life" )
  206.     PORT_DIPSETTING(    0x00, "No Bonus?" )
  207.     PORT_DIPSETTING(    0x01, "100000?" )
  208.     PORT_DIPSETTING(    0x02, "40000?" )
  209.     PORT_DIPSETTING(    0x03, "30000?" )
  210.     PORT_DIPNAME( 0x0c, 0x0c, DEF_STR( Lives ) )
  211.     PORT_DIPSETTING(    0x00, "1" )
  212.     PORT_DIPSETTING(    0x04, "2" )
  213.     PORT_DIPSETTING(    0x08, "3" )
  214.     PORT_DIPSETTING(    0x0c, "5" )
  215.     PORT_DIPNAME( 0x10, 0x00, "Freeze" )
  216.     PORT_DIPSETTING(    0x00, DEF_STR( No ) )
  217.     PORT_DIPSETTING(    0x10, DEF_STR( Yes ) )
  218.     PORT_DIPNAME( 0x20, 0x00, DEF_STR( Unknown ) )
  219.     PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
  220.     PORT_DIPSETTING(    0x20, DEF_STR( On ) )
  221.     PORT_DIPNAME( 0x40, 0x00, DEF_STR( Cabinet ) )
  222.     PORT_DIPSETTING(    0x00, DEF_STR( Upright ) )
  223.     PORT_DIPSETTING(    0x40, DEF_STR( Cocktail ) )
  224.     PORT_DIPNAME( 0x80, 0x00, DEF_STR( Unknown ) )
  225.     PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
  226.     PORT_DIPSETTING(    0x80, DEF_STR( On ) )
  227. INPUT_PORTS_END
  228.  
  229. static struct GfxLayout char_layout =
  230. {
  231.     8,8,
  232.     256,
  233.     4,
  234.     { 0, 8, 256*128,256*128+8 },
  235.     { 7,6,5,4,3,2,1,0 },
  236.     { 0*16, 1*16, 2*16, 3*16, 4*16, 5*16, 6*16, 7*16 },
  237.     128
  238. };
  239.  
  240. static struct GfxLayout tile_layout =
  241. {
  242.     8,8,
  243.     0x100,
  244.     4,
  245.     { 8,12,0,4 },
  246.     { 0,0,1,1,2,2,3,3 },
  247.     { 0*16, 1*16, 2*16, 3*16, 4*16, 5*16, 6*16, 7*16 },
  248.     128
  249. };
  250.  
  251. static struct GfxLayout sprite_layout1 =
  252. {
  253.     32,32,
  254.     128,
  255.     3,
  256.     { 0x4000*8,0x2000*8,0 },
  257.     {
  258.         7,7,6,6,5,5,4,4,3,3,2,2,1,1,0,0,
  259.         0x8000+7,0x8000+7,0x8000+6,0x8000+6,0x8000+5,0x8000+5,0x8000+4,0x8000+4,
  260.         0x8000+3,0x8000+3,0x8000+2,0x8000+2,0x8000+1,0x8000+1,0x8000+0,0x8000+0
  261.     },
  262.     {
  263.          0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8,
  264.          8*8, 9*8,10*8,11*8,12*8,13*8,14*8,15*8,
  265.         16*8,17*8,18*8,19*8,20*8,21*8,22*8,23*8,
  266.         24*8,25*8,26*8,27*8,28*8,29*8,30*8,31*8
  267.     },
  268.     256
  269. };
  270.  
  271. static struct GfxLayout sprite_layout2 =
  272. {
  273.     32,32,
  274.     128,
  275.     3,
  276.     { 0,0,0 },
  277.     {
  278.         7,7,6,6,5,5,4,4,3,3,2,2,1,1,0,0,
  279.         0x8000+7,0x8000+7,0x8000+6,0x8000+6,0x8000+5,0x8000+5,0x8000+4,0x8000+4,
  280.         0x8000+3,0x8000+3,0x8000+2,0x8000+2,0x8000+1,0x8000+1,0x8000+0,0x8000+0
  281.     },
  282.     {
  283.          0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8,
  284.          8*8, 9*8,10*8,11*8,12*8,13*8,14*8,15*8,
  285.         16*8,17*8,18*8,19*8,20*8,21*8,22*8,23*8,
  286.         24*8,25*8,26*8,27*8,28*8,29*8,30*8,31*8
  287.     },
  288.     256
  289. };
  290.  
  291. static struct GfxDecodeInfo gfxdecodeinfo[] =
  292. {
  293.     { REGION_GFX1, 0,      &char_layout,      0,  4 },    /* colors   0- 63 */
  294.     { REGION_GFX2, 0x1000, &tile_layout,     64,  4 },    /* colors  64-127 */
  295.     { REGION_GFX3, 0,      &sprite_layout1, 128, 16 },    /* colors 128-255 */
  296.     { REGION_GFX4, 0,      &sprite_layout2, 128, 16 },    /* colors 128-255 */
  297.     { -1 }
  298. };
  299.  
  300. static struct MachineDriver machine_driver_munchmo =
  301. {
  302.     {
  303.         {
  304.             CPU_Z80,
  305.             3750000, /* ? */
  306.             readmem,writemem,0,0,
  307.             mnchmobl_interrupt,2
  308.         },
  309.         {
  310.             CPU_Z80 | CPU_AUDIO_CPU,
  311.             3750000, /* ? */
  312.             readmem_sound,writemem_sound,0,0,
  313.             nmi_interrupt,1
  314.         }
  315.     },
  316.     57, DEFAULT_REAL_60HZ_VBLANK_DURATION,    /* frames per second, vblank duration */
  317.     1,
  318.     0,
  319.  
  320.     /* video hardware */
  321.     256+32+32, 256, { 0, 255+32+32,0, 255-16 },
  322.     gfxdecodeinfo,
  323.     256,256,
  324.     mnchmobl_convert_color_prom,
  325.  
  326.     VIDEO_TYPE_RASTER,
  327.     0,
  328.     mnchmobl_vh_start,
  329.     mnchmobl_vh_stop,
  330.     mnchmobl_vh_screenrefresh,
  331.  
  332.     /* sound hardware */
  333.     0,0,0,0,
  334.     {
  335.         {
  336.             SOUND_AY8910,
  337.             &ay8910_interface
  338.         }
  339.     }
  340. };
  341.  
  342.  
  343. ROM_START( joyfulr )
  344.     ROM_REGION( 0x10000, REGION_CPU1 ) /* 64k for CPUA */
  345.     ROM_LOAD( "m1j.10e", 0x0000, 0x2000, 0x1fe86e25 )
  346.     ROM_LOAD( "m2j.10d", 0x2000, 0x2000, 0xb144b9a6 )
  347.  
  348.     ROM_REGION( 0x10000, REGION_CPU2 ) /* 64k for sound CPU */
  349.     ROM_LOAD( "mu.2j",     0x0000, 0x2000, 0x420adbd4 )
  350.  
  351.     ROM_REGION( 0x2000, REGION_GFX1 | REGIONFLAG_DISPOSE )
  352.     ROM_LOAD( "s1.10a",     0x0000, 0x1000, 0xc0bcc301 )    /* characters */
  353.     ROM_LOAD( "s2.10b",     0x1000, 0x1000, 0x96aa11ca )
  354.  
  355.     ROM_REGION( 0x2000, REGION_GFX2 )
  356.     ROM_LOAD( "b1.2c",     0x0000, 0x1000, 0x8ce3a403 )    /* tile layout */
  357.     ROM_LOAD( "b2.2b",     0x1000, 0x1000, 0x0df28913 )    /* 4x8 tiles */
  358.  
  359.     ROM_REGION( 0x6000, REGION_GFX3 | REGIONFLAG_DISPOSE )
  360.     ROM_LOAD( "f1j.1g",     0x0000, 0x2000, 0x93c3c17e )    /* sprites */
  361.     ROM_LOAD( "f2j.3g",     0x2000, 0x2000, 0xb3fb5bd2 )
  362.     ROM_LOAD( "f3j.5g",     0x4000, 0x2000, 0x772a7527 )
  363.  
  364.     ROM_REGION( 0x2000, REGION_GFX4 | REGIONFLAG_DISPOSE )
  365.     ROM_LOAD( "h",         0x0000, 0x2000, 0x332584de )    /* monochrome sprites */
  366.  
  367.     ROM_REGION( 0x0100, REGION_PROMS )
  368.     ROM_LOAD( "a2001.clr", 0x0000, 0x0100, 0x1b16b907 ) /* color prom */
  369. ROM_END
  370.  
  371. ROM_START( mnchmobl )
  372.     ROM_REGION( 0x10000, REGION_CPU1 ) /* 64k for CPUA */
  373.     ROM_LOAD( "m1.10e",     0x0000, 0x2000, 0xa4bebc6a )
  374.     ROM_LOAD( "m2.10d",     0x2000, 0x2000, 0xf502d466 )
  375.  
  376.     ROM_REGION( 0x10000, REGION_CPU2 ) /* 64k for sound CPU */
  377.     ROM_LOAD( "mu.2j",     0x0000, 0x2000, 0x420adbd4 )
  378.  
  379.     ROM_REGION( 0x2000, REGION_GFX1 | REGIONFLAG_DISPOSE )
  380.     ROM_LOAD( "s1.10a",     0x0000, 0x1000, 0xc0bcc301 )    /* characters */
  381.     ROM_LOAD( "s2.10b",     0x1000, 0x1000, 0x96aa11ca )
  382.  
  383.     ROM_REGION( 0x2000, REGION_GFX2 )
  384.     ROM_LOAD( "b1.2c",     0x0000, 0x1000, 0x8ce3a403 )    /* tile layout */
  385.     ROM_LOAD( "b2.2b",     0x1000, 0x1000, 0x0df28913 )    /* 4x8 tiles */
  386.  
  387.     ROM_REGION( 0x6000, REGION_GFX3 | REGIONFLAG_DISPOSE )
  388.     ROM_LOAD( "f1.1g",     0x0000, 0x2000, 0xb75411d4 )    /* sprites */
  389.     ROM_LOAD( "f2.3g",     0x2000, 0x2000, 0x539a43ba )
  390.     ROM_LOAD( "f3.5g",     0x4000, 0x2000, 0xec996706 )
  391.  
  392.     ROM_REGION( 0x2000, REGION_GFX4 | REGIONFLAG_DISPOSE )
  393.     ROM_LOAD( "h",         0x0000, 0x2000, 0x332584de )    /* monochrome sprites */
  394.  
  395.     ROM_REGION( 0x0100, REGION_PROMS )
  396.     ROM_LOAD( "a2001.clr", 0x0000, 0x0100, 0x1b16b907 ) /* color prom */
  397. ROM_END
  398.  
  399.  
  400. GAME( 1983, joyfulr,  0,       munchmo, mnchmobl, 0, ROT270, "SNK", "Joyful Road (US)" )
  401. GAME( 1983, mnchmobl, joyfulr, munchmo, mnchmobl, 0, ROT270, "SNK (Centuri license)", "Munch Mobile (Japan)" )
  402.